import axios from 'axios';
import { BASE_CONFIG } from './config';
import {
  requestErrInterceptor,
  requestInterceptor,
  responseInterceptor,
  responseErrInterceptor
} from './interceptors';

const { base, contentType, timeout } = BASE_CONFIG;
const instance = axios.create({
  baseURL: base,
  timeout: timeout,
  headers: {
    'Content-Type': contentType
  }
});

instance.interceptors.request.use(requestInterceptor, requestErrInterceptor);

instance.interceptors.response.use(responseInterceptor, responseErrInterceptor);

export default instance.request;
